/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package testingall;

/**
 *
 * @author parallels
 */
final public class MyArray {
    
    private int [] myRef;
    private int maxSize;
    private int size;
    
    public MyArray (int size) {
        assert (size > 0);
        myRef = new int [size];
        maxSize = size;
        this.size = 0;
    }
    
    public int size () {
        return size;
    }
    
    public int get (int pos) {
        assert (pos < size && pos >= 0) : 
                "array index out of bounds = " + pos;
        return myRef [pos];
    }
    
    public void put (int elem) {
        assert (size < maxSize) : 
                "array size exceeded (pos=" + size 
                + ", size=" + maxSize + ")";
        myRef [size] = elem;
        size = ++size;
    }
    
}
